// 表格列配置
export const options = [
  {
    label: "菜单名称",
    prop: "menuName",
    width: "150",
  },
  {
    label: "图标",
    prop: "menuIcon",
    width: "70",
  },
  {
    label: "路径",
    prop: "menuPath",
    width: "280",
  },
  {
    label: "组件",
    prop: "menuComponent",
    width: "150",
  },
  {
    label: "类型",
    prop: "menuType",
    width: "80",
    formatter: (row) => {
      const typeMap = {
        0: "目录",
        1: "菜单",
        2: "按钮",
      };
      return typeMap[row.menuType] || "未知";
    },
  },
  {
    label: "排序",
    prop: "menuSortNo",
    width: "70",
  },
  {
    label: "权限标识",
    prop: "menuAuthority",
    width: "120",
  },
  {
    label: "隐藏",
    prop: "menuHide",
    width: "70",
    formatter: (row) => (row.menuHide ? "是" : "否"),
  },
  {
    label: "创建时间",
    prop: "menuCtime",
    width: "180",
    formatter: (row) => new Date(row.menuCtime).toLocaleString(),
  },
];

// 表单校验规则
export const rules = {
  menuName: [{ required: true, message: "请输入菜单名称", trigger: "blur" }],
  menuPath: [{ required: true, message: "请输入菜单路径", trigger: "blur" }],
  menuType: [{ required: true, message: "请选择菜单类型", trigger: "change" }],
  menuSortNo: [
    { required: true, message: "请输入排序号", trigger: "blur" },
    { type: "number", message: "排序号必须为数字", trigger: "blur" },
  ],
};

// 表单默认值
export const defaultForm = {
  menuName: "",
  menuIcon: "",
  menuPath: "",
  menuComponent: "",
  menuType: 1,
  menuSortNo: 0,
  menuAuthority: "",
  menuHide: false,
  menuParentId: 0,
};

// 菜单类型选项
export const typeOptions = [
  {
    value: 0,
    label: "目录",
  },
  {
    value: 1,
    label: "菜单",
  },
  {
    value: 2,
    label: "按钮",
  },
];
